﻿<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Agenda Posgrad - Meus Processos</title>
<%@ include file="../../includes/head.jsp" %>

<script type="text/javascript">
	$(function() {
		$("#abas").tabs().find(".ui-tabs-nav").sortable({axis:'x'});
	});
</script>

<script type="text/javascript">
	$(function() {
		
		$("#dialog-detalhes-proposta").dialog({
			autoOpen: false,
			modal: true,
			beforeclose: function(event, ui) {
				$('#content_proposta',this).text("");
				proposta_id = 0;
			},
			buttons: {
				"Visualizar Proposta": function() {
					//window.open("admin/propostas/pdf/"+proposta_id,"","width=250,height=300,status=yes,toolbar=no,menubar=no");
					$("<a/>").attr("href","admin/propostas/pdf/"+proposta_id).attr("target","_blank").click();
				}
				//"Ver Anexo": 	function() {window.open("blank.htm"+proposta_id,"","width=800,height=600,status=yes,toolbar=no,menubar=no");}
			}
		});		
		
		$(".btn-detalhes-proposta").click(function (event) {
			var loader = $('#loader_proposta');
			var dialog = $('#dialog-detalhes-proposta');
			var content	= $('#dialog-detalhes-proposta #content_proposta');
			var nome = $(this).attr("alt");
			var title = "Detalhes da Proposta de " + nome;

			loader.show();
			event.preventDefault();
			dialog.dialog("option" , "title" , title);
			dialog.dialog('open');
			content.load($(this).attr("href"), function() {
				$('#loader_proposta').hide();					
				proposta_id = $("#proposta_id").val();
			});
			loader.hide();
		});
	});
</script>
</head>

<body>
<%@ include file="../includes/topo.jsp" %>
		
		<div id="nome_acao">Solicitar Defesa</div>
		
		<div id="abas">
			<ul>
				<li><a href="#aba-1">Propostas</a></li>
			</ul>
			<div id="aba-1">
				<c:choose>
					<c:when test="${empty propostas}">
						<p>Nenhuma proposta</p>
					</c:when>
					<c:otherwise>
			        	<table width="100%" bordercolor="#000000" border="0" cellspacing="3" cellpadding="2">
			              <tr>
			                <th>Nº Processo</th>
			                <th>Data solicitação</th>
			                <th>Nome do Aluno</th>
			                <th>Status</th>
			                <th>Ação</th>
			              </tr>
			              <c:forEach items="${propostas}" var="proposta" varStatus="c">
			              <tr>
			                <td align="center" bgcolor="#A7D7ED"><fmt:formatNumber value="${proposta.id}" minIntegerDigits="4" groupingUsed=""/></td>
			                <td align="center" bgcolor="#A7D7ED"><fmt:formatDate value="${proposta.data_proposta}" pattern="dd/MM/yyyy"/></td>
			                <td align="center" bgcolor="#A7D7ED">${proposta.aluno.nome}</td>
			                <td align="center" bgcolor="#A7D7ED" ${proposta.status.name eq 'APROVADO' ? 'style="color:green;"':'style="color:red;"'}>${proposta.status.descricao}</td>
			                <td align="center" bgcolor="#A7D7ED">
			                	<c:choose>
				                	<c:when test="${proposta.status.name eq 'APROVADO'}">
				                		<a href="admin/defesas/solicitar-${proposta.id}" class="btn" style="color: green">Solicitar defesa</a>
				                		<a href="admin/propostas/${proposta.id}" class="btn btn-detalhes-proposta" alt="${proposta.aluno.nome}" id="${proposta.id}" >Detalhes</a>
				                	</c:when>
				                	<c:otherwise>
				                		--
				                	</c:otherwise>
			                	</c:choose>
							</td>
			              </tr>
			              </c:forEach>
			              
			            </table>
					</c:otherwise>
				</c:choose>
			</div>
		</div>   

<div id="dialog-detalhes-proposta" title="Detalhes da Proposta #">
	<center><img src="static/imagens/ajax-loader.gif" id="loader_proposta"/></center>
	<div id="content_proposta">
	</div>
</div>

<%@ include file="../../includes/rodape.jsp" %>
</body>
</html>